export function convertRouter(routes) {
    return routes.map((route) => {
        if (route.component) {
            let index = -1;
            let path = '';
            if (route.component.indexOf('layouts') !== -1) {
                index = route.component.indexOf('layouts')
                path =
                    index > 0 ? route.component.slice(index) : `layouts/${route.component}`
            } else {
                index = route.component.indexOf('views')
                path =
                    index > 0 ? route.component.slice(index) : `views/${route.component}`
            }

            route.component = (resolve) => require([`@/${path}`], resolve)
        }
        if (route.children && route.children.length > 0) {
            route.children = convertRouter(route.children)
        }
        if (route.children && route.children.length === 0) delete route.children
        return route
    })
}